using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// 单例模式；保证一个类仅有一个实例，并提供一个访问它的全局访问点

/// <summary>
/// 单例模式 
/// </summary>
/// <typeparam name="T"></typeparam>
public class Singleton<T> where T:new()
{

    private static T _instance;

    public static T Instance
    {
        get
        {
            if (_instance == null)
            {
                _instance = Activator.CreateInstance<T>();
            }

            return _instance;
        }
    }
}
